package com.zmn.plat.common.dictionary;

/**
 * 渠道推广方式枚举
 *
 * @author linfeng
 * @since 2020/11/21 09:43
 */
public enum ChannelPromotionTypeEnum {

    /**
     * values
     */
    NONE(1, "无"),
    TOUTIAO(2, "头条"),
    BAIDU(3, "百度");

    private Integer code;
    private String name;

    ChannelPromotionTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static ChannelPromotionTypeEnum of(Integer code) {
        if(code == null){
            return null;
        }
        switch (code) {
            case 1:
                return NONE;
            case 2:
                return TOUTIAO;
            case 3:
                return BAIDU;
            default:
                return NONE;
        }
    }

    public static String getName(Integer code) {
        ChannelPromotionTypeEnum of = of(code);
        return of == null ? null : of.getName();
    }

    public static ChannelPromotionTypeEnum[] list() {
        return new ChannelPromotionTypeEnum[]{NONE, TOUTIAO, BAIDU};
    }
}
